package com.tencent.wxcloudrun.controller.fangdong;

import com.tencent.wxcloudrun.config.ApiResponse;
import com.tencent.wxcloudrun.pojo.dto.resp.GetCurLiveDetailResp;
import com.tencent.wxcloudrun.pojo.dto.resp.GetTenantListResp;
import com.tencent.wxcloudrun.service.business.fangdong.TenantManageService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/tenantManage")
public class TenantManageController {

    @Resource
    private TenantManageService tenantManageService;

    /**
     * 获取当前房东的租客列表
     */
    @GetMapping("/getTenantList")
    public ApiResponse<List<GetTenantListResp>> getTenantList() {
        return new ApiResponse<>(tenantManageService.getTenantList());
    }

    /**
     * 获取当前租客的详细租房信息
     * <p>
     * 前端要根据houseId去处理好房屋信息的问题
     */
    @GetMapping("/getCurLiveDetail")
    public ApiResponse<GetCurLiveDetailResp> getCurLiveDetail(@RequestParam("liveId") String liveId) {
        return new ApiResponse<>(tenantManageService.getCurLiveDetail(liveId));
    }

    /**
     * 租客的电话号码
     */
    @GetMapping("/getTenantPhone")
    public ApiResponse<String> getTenantPhone(@RequestParam("liveId") String liveId) {
        return new ApiResponse<>(tenantManageService.getTenantPhone(liveId));
    }

    /**
     * 强制退租
     */
    @GetMapping("/forceExpel")
    public ApiResponse<String> forceExpel(@RequestParam("liveId") String liveId) {
        return new ApiResponse<>(tenantManageService.forceExpel(liveId));
    }
}
